<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title></title>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap.min.css">
<link rel="stylesheet" href="js/bootstrap2/css/bootstrap-table.css">
<link rel="stylesheet" href="css/common.css">
<script type="text/javascript" src="js/jquery-1.11.1.js"></script>
<script src="js/bootstrap2/js/bootstrap-table.js"></script>
<script src="js/bootstrap2/js/bootstrap-table-zh-CN.js"></script>
<style type="text/css">

.content-search{
  padding-right: 20px;
}
.top-search {
	padding-top: 10px;
	height: 35px;
}

.top-search div {
	float: left;
	vertical-align: middle;
}

.top-search div:nth-child(1) {
	margin-right: 20px;
}


.list-center {
	height: 55px;
	padding: 10px 0px 0px 5px;
	font-size: 15px;
}


.btn {
	padding: 4px 6px;
	line-height: 16px;
}

.right{text-align: right}
</style>
</head>
<body>
	<div class='wrapper'>
		<div class="top-search">
			<div>
				<span>客户类型</span> <input type="text">&nbsp;&nbsp;
				<span>客户名称</span> <input type="text">
			</div>
			<div>
				<button type="button" class="btn btn-danger radius">查询</button>
			</div>
		</div>
		<div class="content-search">
			<!-- 列表start -->
			<div style="padding-top: 5px;">
				<table id="table">

				</table>
			</div>
			<!-- 列表end -->
		</div>
	</div>
	<script type="text/javascript">
		//表格-操作 - 格式化 
		function actionFormatter(value, row, index) {
			return "<a class='btn btn-info' onClick='openCustomerDetail(\"" + row.id + "\")'>查看详情</a>&nbsp;&nbsp;<a class='btn btn-info' onClick='changeCustomerStatus(\"" + row.id + "\")'>恢复</a>";
		}
		
		//打开新增客户页面
		function openCustomerDetail(data_id) {
			//var data_id=$(this).parent().parent().attr("data-id");
			//有值代表点击的是某个客户的编辑按钮，无值代表点击新增用户
			if(!(data_id==null)){
				customerId=data_id;
			}else{
				customerId="-";
			}
			parent.parent.layer.open({
				type : 2,
				title : '客户信息',
				shadeClose : false,
				shade : 0.1,
				maxmin : true, //开启最大化最小化按钮
				area : [ '90%', '80%' ],
				end:parent.updateRoom,//销毁回调
				content : 'customerInfo/toCustomerDetail/' + parent.roomId + '/' + parent.status + '/' + customerId+'/'+top.projectID
			});
		}
		//将客户从历史状态恢复
		function changeCustomerStatus(id){
			parent.parent.layer.confirm('点击确定后客户状态恢复成在住状态', {
			  btn: ['确定','取消'] //按钮
			}, function(){
			  //点击确定时，删除该条数据
				$.ajax({
					url : "customerInfo/changeCustomerStatus", //请求的url地址
					async : true, //请求是否异步，默认为异步
					data : {
						"id" : id
					}, //参数值
					type : "GET", //请求方式
	
					success : function(req) {
						if (req.success) {
							parent.parent.layer.msg("操作成功", {
								anim : 5,
								time : 1500
							}, function() {
								
								//location.reload();
								//刷新房间列表并重新点击被选中的房间
								parent.updateRoom();
							});
	
						}else{
							parent.parent.layer.msg(req.msg, {
								anim : 5,
								time : 1500
							}, function() {
							//刷新房间列表并重新点击被选中的房间
								//location.reload();
								parent.updateRoom();
							});
						}
					}
				});
			}, function(){
			  parent.parent.layer.close();
			});
		
		}
		
		function typeFormatter(value, row, index){
			var type;
			if(value==1){
				type = "法人";
			}else{
				type="自然人";
			}
			return type;
		}
		//日期格式化
		function dataFormat(value, row, index) {
			return new Date(row.createDate).format("yyyy-MM-dd");
		}
		
		$(function() {
			var historyStatus = '1'; 
			var fkroomId = parent.roomId;
			//先销毁表格  
			//$('#table').bootstrapTable('destroy');  
			//初始化表格,动态从服务器加载数据  
			$("#table").bootstrapTable({
				method : "post", //使用get请求到服务器获取数据  
				url : "customerInfo/getHistoryCustomerInfoList", //获取数据的Servlet地址  
				striped : true, //表格显示条纹  
				pagination : true, //启动分页  
				pageSize : 2, //每页显示的记录数  
				pageNumber : 1, //当前第几页  
				pageList : [ 5, 10, 15, 20, 25 ], //记录数可选列表  
				sidePagination : "server", //表示服务端请求  
				contentType : 'application/x-www-form-urlencoded',
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder  
				//设置为limit可以获取limit, offset, search, sort, order  
				queryParamsType : "undefined",
				queryParams : function queryParams(params) { //设置查询参数  
					var param = {
						pageNumber : params.pageNumber,
						pageSize : params.pageSize,
						fkroomId : fkroomId,
						status:historyStatus
					};
					return param;
				},
				columns : [ {
					field : 'customerType',
					title : '客户类型',
					formatter : 'typeFormatter'
				}, {
					field : 'name',
					title : '客户名称',
				}, {
					field : 'tel',
					title : '固定电话',
				}, {
					field : 'duty',
					title : '职务',
				//align : "left"
				}, {
					field : 'sortNum',
					title : '备注',
				//align : "left"
				}, {
					field : 'opr',
					title : '操作',
					width : '15%',
					formatter : 'actionFormatter'
				} ]
			});
		})
	</script>
</body>
<script src="js/bootstrap2/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/layui-v2.1.5/layui/layui.all.js"></script>
<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script> 
</html>